<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>envlpxr</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="envlpx.html" title="envlpx" />
    <link rel="next" href="ephasor.html" title="ephasor" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">envlpxr</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="envlpx.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ephasor.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="envlpxr"></a>
      <div class="titlepage"></div>
      <a id="IndexEnvlpxr" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">envlpxr</span>
        </h2>
        <p>envlpxr — 
      The <span class="emphasis"><em>envlpx</em></span> opcode with a final release segment.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp101096384"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>envlpxr</em></span> is the same as <a class="link" href="envlpx.html" title="envlpx"><em class="citetitle">envlpx</em></a> except that the final segment is entered only on sensing a MIDI note release. The note is then extended by the decay time.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp101099088"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>envlpxr</strong></span> xamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]</pre>
        <pre class="synopsis">kres <span class="command"><strong>envlpxr</strong></span> kamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]</pre>
      </div>
      <div class="refsect1">
        <a id="idp101102720"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>irise</em></span> -- rise time in seconds. A zero or negative value signifies no rise modification.
    </p>
        <p>
      <span class="emphasis"><em>idec</em></span> -- decay time in seconds. Zero means no decay.
    </p>
        <p>
      <span class="emphasis"><em>ifn</em></span> -- function table number of stored rise shape with extended guard point.
    </p>
        <p>
      <span class="emphasis"><em>iatss</em></span> -- attenuation factor, by which the last value of the <span class="emphasis"><em>envlpxr</em></span> rise is modified during the note's pseudo steady state. A factor greater than 1 causes an exponential growth and a factor less than 1 creates an exponential decay. A factor of 1 will maintain a true steady state at the last rise value.  Note that this attenuation is not by fixed rate (as in a piano), but is sensitive to a note's duration. However, if <span class="emphasis"><em>iatss</em></span> is negative (or if steady state &lt; 4 k-periods) a fixed attenuation rate of <span class="emphasis"><em>abs</em></span>(<span class="emphasis"><em>iatss</em></span>) per second will be used. 0 is illegal.
    </p>
        <p>
      <span class="emphasis"><em>iatdec</em></span> -- attenuation factor by which the closing steady state value is reduced exponentially over the decay period. This value must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.
    </p>
        <p>
      <span class="emphasis"><em>ixmod</em></span> (optional, between +- .9 or so) -- exponential curve modifier, influencing the steepness of the exponential trajectory during the steady state. Values less than zero will cause an accelerated growth or decay towards the target (e.g. <span class="emphasis"><em>subito piano</em></span>). Values greater than zero will cause a retarded growth or decay. The default value is zero (unmodified exponential).
    </p>
        <p>
      <span class="emphasis"><em>irind </em></span> (optional) -- independence flag. If left zero, the release time (<span class="emphasis"><em>idec</em></span>) will influence the extended life of the current note following a note-off. If non-zero, the <span class="emphasis"><em>idec</em></span> time is quite independent of the note extension (see below). The default value is 0.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp101113984"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kamp, xamp</em></span> -- input amplitude signal.
    </p>
        <p>
      <span class="emphasis"><em>envlpxr</em></span> is an example of the special Csound <span class="quote">“<span class="quote">r</span>”</span> units that contain a note-off sensor and release time extender. When each senses a score event termination or a MIDI noteoff, it will immediately extend the performance time of the current instrument by <span class="emphasis"><em>idec</em></span> seconds unless it is made independent by <span class="emphasis"><em>irind</em></span>. Then it will begin a decay from wherever it was at the time. 
    </p>
        <p>
      You can use other pre-made envelopes which start a release segment upon recieving a note off message, like <a class="link" href="linsegr.html" title="linsegr"><em class="citetitle">linsegr</em></a> and <a class="link" href="expsegr.html" title="expsegr"><em class="citetitle">expsegr</em></a>, or you can construct more complex envelopes using <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a> and <a class="link" href="release.html" title="release"><em class="citetitle">release</em></a>. Note that you don't need to use <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a> if you are using <span class="emphasis"><em>envlpxr</em></span>, since the time is extended automatically.
    </p>
        <p>
      These <span class="quote">“<span class="quote">r</span>”</span> units can also be modified by MIDI noteoff velocities (see veloffs). If the <span class="emphasis"><em>irind</em></span> flag is on (non-zero), the overall performance time is unaffected by note-off and veloff data.
    </p>
        <p><strong>Multiple <span class="quote">“<span class="quote">r</span>”</span> units. </strong>
         When two or more <span class="quote">“<span class="quote">r</span>”</span> units occur in the same instrument it is usual to have only one of them influence the overall note duration. This is normally the master amplitude unit. Other units controlling, say, filter motion can still be sensitive to note-off commands while not affecting the duration by making them independent (<span class="emphasis"><em>irind</em></span> non-zero). Depending on their own <span class="emphasis"><em>idec</em></span> (release time) values, independent <span class="quote">“<span class="quote">r</span>”</span> units may or may not reach their final destinations before the instrument terminates. If they do, they will simply hold their target values until termination. If two or more <span class="quote">“<span class="quote">r</span>”</span> units are simultaneously master, note extension is by the greatest <span class="emphasis"><em>idec</em></span>.
      </p>
      </div>
      <div class="refsect1">
        <a id="idp101130096"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the envlpxr opcode. It uses the file <a class="ulink" href="examples/envlpxr.csd" target="_top"><em class="citetitle">envlpxr.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp101131952"></a>
          <p class="title">
            <strong>Example 224. Example of the envlpxr opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  -+rtmidi=virtual -M0   <span class="comment">;;;realtime audio out and realtime midi in</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o envlpxr.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> 1
 	 
icps	<span class="opc">cpsmidi</span>	 	 
iamp	<span class="opc">ampmidi</span>	.5	 
 	 	 	 
kenv	<span class="opc">envlpxr</span>	iamp, 0.2, 1, 1, 1, .01
asig	<span class="opc">pluck</span>	kenv, icps, 200, 2, 1	 
	<span class="opc">outs</span>	asig, asig
	 
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 129 -7 0 128 1
<span class="stamnt">f</span> 2 0 4096 10 1	

<span class="stamnt">f</span>0 30	<span class="comment">;runs 30 seconds</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp101133920"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="envlpx.html" title="envlpx"><em class="citetitle">envlpx</em></a>,
      <a class="link" href="linen.html" title="linen"><em class="citetitle">linen</em></a>,
      <a class="link" href="linenr.html" title="linenr"><em class="citetitle">linenr</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp101137888"></a>
        <h2>Credits</h2>
        <p>Thanks goes to Luis Jure for pointing out a mistake with <span class="emphasis"><em>iatss</em></span>.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="envlpx.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ephasor.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">envlpx </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ephasor</td>
        </tr>
      </table>
    </div>
  </body>
</html>
